<?php


namespace App\Http\Controllers\admin\api;


use App\Http\Controllers\admin\service\FileService;
use App\Http\Controllers\admin\validate\File;
use App\Http\Controllers\utils\ToolUtil;
use Illuminate\Http\Request;

class FileApi
{
    public function addFile(Request $request){
        $param = $request->all();
        $data = File::addFile($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return FileService::addFile($param);
    }

    public function queryFile(Request $request){
        $param = $request->all();
        $data = File::queryFile($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return FileService::queryFile($param);
    }

    public function queryIdFile(Request $request){
        $param = $request->all();
        $data = File::queryIdFile($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return FileService::queryIdFile($param);
    }

    public function editFile(Request $request){
        $param = $request->all();
        $data = File::editFile($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return FileService::editFile($param);
    }

    public function deleteFile(Request $request){
        $param = $request->all();
        $data = File::deleteFile($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return FileService::deleteFile($param);
    }
    public function getFileType(Request $request){
        $param = $request->all();
        $data = File::getFileType($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return FileService::getFileType($param);
    }

    public function uploadFile(Request $request){
        $param = $request->all();
        $data = File::uploadFile($param);
        if($data){
            return ToolUtil::returnJson(401,$data[0]);
        }
        return FileService::uploadFile($param);
    }


}